<!DOCTYPE HTML>
<html>
	 <head>
		 <meta http-equiv="content-type" content="text/html;charset=utf-8">
		 <title> New Document </title>
		 <script src="__JQ__/jquery.js"></script>
		 <link rel="stylesheet" href="__JQ__/jqueryUI/jquery-ui.theme.min.css">
		 <script src="__JQ__/jqueryUI/jquery-ui.min.js"></script>
		<script type="text/javascript" src="__JQ__/admin-js.js"></script>
		 <style>
		 .biaod{margin-left:-30px}
		 .msg{background-color:#1C86EE;width:200px;height:30px;position:absolute;left:50%;margin-left:-100px;border-radius:8px;display:none;color:white}
		.v-edit{display:none}
		 </style>
	 </head>
	 <body>
		<!-- 订单详情列表表单 -->		
		<form method="post" action="" name="listForm" class="v-edit">
			<input type="hidden" name="id">
			<div id="tanchu1" style="border:4px solid #999; background-color:#FFF;" >
				<div style="line-height:25px;  font-size:16px;padding-left:40px;padding-bottom:10px;padding-top:10px;">
					<div>						
						<br/>评论用户：<input type="text" name="uname" value="">
						<br/>评论时间：<input type="text" name="add_time" value="">	
						<br/>评论内容：<textarea name="content" rows="" cols=""></textarea>
					</div>					
				</div>
			</div>
		</form>
	 <!--订单列表显示-->
	<div class="msg" align="center"></div>
<form action="<{:U('commentList')}>" method="post">
	<div class="select_order" style="height:40px; width:96%;padding-left:20px;
		margin-bottom:15px;border:1px solid #ccc;font-size:14px;padding-top:6px;">
		用户名：<input type="text" name="uname" value='' id="uname"> 
		审核状态：<select id="review" name="review">
						<option value="0">--全部--</option>
						<option value="1">--已审核--</option>
						<option value="2">--未审核--</option>
						<option value="3">--未通过--</option>
					</select> &nbsp;
		评论类别： <select id="fid" name="fid">
						<option value="0">--全部评论--</option>
						<option value="1">--普通评论--</option>
						<option value="2">--回复评论--</option>			
					</select> &nbsp;
		<input type="submit" name="sub" value="搜索"  style="border:none; background-color:#F90;cursor:pointer;"/>
	</div>
</form>
	 <!-- 订单列表表单 -->
	<div class="biaod">
	  <form method="post" action="" name="listForm"> 
		<table class="list_table" id="listtable" width="95%" border="0" cellpadding="2" cellspacing="1" bgcolor="#CFCFCF" align="center" style="margin-top:8px">
		<thead> 
		<tr align="center" bgcolor="#FBFCE2" height="25">
			<th class="id">编号</th>
			<th><input id="s_all" type="checkbox">选择</th>
			<th class="pid"> 商品编号<img src="__IMAGE__/sort_desc.gif"/></th>
			<th class="uname"> 用户名</th>
			<th class="add_time">评论时间</th>
			<th class="review">审核情况</th>
			<th class="fid">评论类别</th>
			<th class="operate">操作</th>
		</tr>
		</thead>
		<tbody> 
	   <volist name="res" id="v">	   
	   <tr align="center" bgcolor="#FFFFFF" height="26" align="center" border=1 onMouseMove="javascript:this.bgColor='#FCFDEE';" onMouseOut="javascript:this.bgColor='#FFFFFF';" id="order_<{$v.id}>" >
			<td><{$v.id}></td>
		    <td class="num"><input type="checkbox" name="row[]" value="<{$v.id}>" class="c1"></td>
			<td><{$v.pid}></td>
			<td align="center" class="uname"><span class="uname"><{$v.uname}></span></td>
			<td align="center" class="add_time"><{$v.add_time|date="Y-m-d H:i:s",###}></td>	
			<td align="center" class="review"><span class="review">
									<switch name="v.review">
											<case value="0">全部</case>
											<case value="1">已审核</case>
											<case value="2">未审核</case>
											<case value="3">未通过</case>
											
										</switch></span></td>
			<td align="center" class="fid"><span class="fid">
									<switch name="v.fid">
										<case value="0">全部评论</case>
										<case value="1">普通评论</case>    
										<case value="2">回复评论</case>
									</switch></span></td>
									
			</td>
			<td align="center" class="operate" >
			  <a href="<{:U('commentdetail')}>?id=<{$v.id}>"><input type="button" border=0 value="查看" name="view" data-oid="<{$v.id}>" width=16 height=16/></a> 
			  <input type="button" border=0  value="编辑" data-oid="<{$v.id}>" name="edit" width=16 height=16>		 
			  <input type="button" border=0 value="删除"  data-oid="<{$v.id}>" name="del" width=16 height=16></td>
		   </tr>
	   </volist>
	    <tr align="left" bgcolor="#CCCCCC">
			<td colspan=8  height="40px" id="widget2">
				<input type="button" name="add" value="添加订单">
				<input type="button" id="f_all" value="反选" >
				<input type="button" value="删除" name="dele"><div style="float:right;margin-top:10px"><{$page}></div>
			</td>
		</tr>
	 </tbody>
	</table>
	</form>
  </div>
		<script>
		//搜索框自动完成
		$( function() {
			 $( "#uname" ).autocomplete({
			  source: "<{:U('search1')}>",			  
			});
		});

		//全选反选
		$(function(){	
			$('#s_all').click(function(){
				$('.c1').prop('checked',$(this).prop('checked'));	
			});
		
			$('#f_all').click(function(){
				$('.c1').map(function(k,v){
					var flag = $(v).prop('checked');
					$(v).prop('checked',!flag);
				});			
			});
		});

	//删除单个弹窗
	$(function(){
	$('[name="del"]').click(function(){
		var id = $(this).attr('data-oid');
		$( "<div>确定删除吗?</div>" ).dialog({
		  resizable: false,
		  title:"删除",
		  height: "auto",
		  width: 350,
		  modal: true,
		  buttons: {
			"确认删除": function() {
			  $( this ).dialog( "close" );
			  $.get('<{:U("comDel")}>',{id:id},function(data){
			if(data.status){				
				$('#order_'+id).remove();
				$('.msg').text(data.msg);
				$('.msg').slideDown('fast');
				setTimeout(function(){$('.msg').slideUp('fast');},1600);				
			}		
			},'json');
			refresh();
			
			},
			"取消": function() {
			  $( this ).dialog( "close" );
			}
		  }
		});
	});

	//刷新当前页面.
	function refresh(){
		window.location.reload();//刷新当前页面.				 
	}
	
	
	//可删除多个的弹窗
  $( function() {
		$('[name="dele"]').click(function(){
			var arr = [];      
		$('input:checked').each(function(){   //所有为checked状态的多选框   
			arr.push(this.value);  
		});  
		if(arr.length == 0 ){ 
		  $( '<div>请选择需要删除的记录</div>').dialog({
		  resizable: false,
		  title:"!提示",
		  height: "auto",
		  width: 350,
		  modal: true,
		  buttons: {
			"确定": function() {
				$( this ).dialog( "close" );
			
			},
		  }
		}); 
			return;  
		}  		
		var len = $("input[name='row[]']:checked").length;
		console.log(len);
		console.log(arr);
		$( '<div>确定删除这<font color="red">'+len+'</font>项吗?删除后不可恢复!</div>').dialog({
		  resizable: false,
		  title:"删除",
		  height: "auto",
		  width: 350,
		  modal: true,
		  buttons: {
			"确认删除": function() {
				$( this ).dialog( "close" );
			  $.post('<{:U("Del")}>',{arr:arr},function(data){
			if(data.status){				
				$("input[name='row[]']:checked").each(function() {              
				$(this).parent().parent().remove(); 
				});
				$('.msg').text(data.msg);
				$('.msg').slideDown('fast');
				setTimeout(function(){$('.msg').slideUp('fast');},1600);				
				}
			},'json');
			refresh();
			},
			"取消": function() {
			  $( this ).dialog( "close" );
			}
		  }
		});
	  });
   });
});

//编辑弹窗
$('[name="edit"]').click(function(){
		var id = $(this).attr('data-oid');
		$('.v-edit [name="id"]').val(id);
		$.get('<{:U("chaxun")}>',{id:id},function(data){
			console.log(data);			
			$('.v-edit [name="uname"]').val(data.uname);
			$('.v-edit [name="add_time"]').val(data.add_time);
			$('.v-edit [name="content"]').text(data.content);
		},'json');
		
		$( '.v-edit' ).dialog({
		  resizable: false,
		  title:"评论修改：",
		  height: "auto",
		  width: 400,
		  modal: true,
		  buttons: {
			"确认编辑":  		
				function() {						  
			  $.post('<{:U("view")}>',{id:id},function(data){
				$('#order_'+id+' td:eq(7)').text("已经发货");
				$('.msg').text(data.msg);
				$('.msg').slideDown('fast');
				setTimeout(function(){$('.msg').slideUp('fast');},1600);			
				},'json');
				$( this ).dialog( "close" );
				},
				"取消": function() {
				  $( this ).dialog( "close" );
			}
		  }
		});
		
	});
		</script>
	 </body>
</html>
